package cc.yiueil.service;

import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

@Service
public class UserService implements UserDetailsService {
    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        if ("YIueil".equals(username)) {
            return User.builder()
                    .username("YIueil")
                    .password("{noop}123456")
                    .roles("USER")
                    .build();
        }
        throw new UsernameNotFoundException(String.format("%s: not found", username));
    }
}
